package gui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

/**
 * Makes a button that when pressed clears the URL field in BotGui.
 * @author Jamison Bradley
 */
public class ClearButton extends JButton{
	/**
	 * Default Serialization
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * The text field that contains the url of the city being edited.
	 */
	private JTextField url;
	/**
	 * The text area that contains the Wikipedia page source.
	 */
	private JTextArea code;
	
	/**
	 * Constructs the clear button.
	 * @param urlText is the text field containing the url of the city being edited.
	 */
	public ClearButton(JTextField urlText, JTextArea pageSource){
		super("Clear Url");
		url = urlText;
		code = pageSource;
		
		addActionListener(new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent e) {
				url.setText("");
				code.setText("");
			}
		});
	}
}
